Repository navigation
feat(editor): annotation typing, callback highlighting and quote-aware snippets - #5
Merged
Merged
Conversation
The language server continues `---@` annotation lines on Enter through on-type formatting, which VS Code only runs with editor.formatOnType. Turn it on for Lua by default and cover the continuation and clearing in the extension tests.
List editor.action.triggerSuggest under the client's experimental.commands.commands capability, the way rust-analyzer's client lists the commands it runs. The language server then attaches it to call snippets of ---@callback await and trigger wrappers, so the registered callback names are suggested as soon as the call is inserted.
VS Code's Lua grammar scopes `---` comments as comment.line.double-dash.documentation.lua and colors the tags it knows. A new injection into those comments adds what it leaves plain: the role and family of `---@callback register shop`, attribute lists such as `(exact, server)` after @Class, @alias, @enum, @field and @overload, and the visibility keyword of @field, which the built-in rule read as the field name. The rest of each line keeps the built-in colors.
Turn on editor.suggest.preview for Lua by default, so the rest of the selected completion shows in gray at the cursor, e.g. `---@p` previews `aram`, and Tab accepts it.
VS Code does not suggest while typing in comments, so the `---@` that Enter adds to an annotation block showed no tags until Ctrl+Space. The extension now opens the tag list when the first letter is typed after `---@`. The list does not open on the bare `---@` itself, so Enter there still clears it.
Showing an editor for a file outside any repository makes the built-in Git extension run `git rev-parse --show-toplevel` in that file's folder. On Windows a running process's working directory cannot be removed, so the snippet test that opens the personal library and cleans up right away failed with EBUSY on rmdir 'profile'. Retry the removal briefly.
The fxmanifest and config module snippets were a static snippets contribution, always written with single quotes. A completion provider now offers them under the same prefixes, in the quote the language server reports through qbx/quote: the formatter's quote_style, or else the quote most strings of the document use. The snippet browser shows its manifest recipes the same way, and the resource wizard writes the new fxmanifest.lua in the configured quote, `'` when it is preserve. Without a running server, all of them keep single quotes. As they are no longer contributed snippets, VS Code's Insert Snippet list leaves them out; the snippet browser still lists them.
…rules The language server now keeps the rule levels a `qbxlint.toml` sets, and `qbxLua.diagnostics.rules` only sets the level of the remaining rules. The setting's description and the README said it overrides rule levels.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The VS Code side of the language server work in Qbox-project/qbx-lua#12. Only the VS Code extension changes.
Typing annotations
editor.formatOnTypeis on for Lua by default. The server continues---@annotation lines on Enter through on-type formatting, which VS Code only runs with that setting.---@opens the tag list. VS Code does not suggest while typing in comments, so the list only appeared on Ctrl+Space before. It stays closed on a bare---@, so Enter there still clears the line.editor.suggest.previewis on for Lua by default, so the rest of the selected suggestion shows in gray at the cursor.Suggestions after a completion
The client lists
editor.action.triggerSuggestunderexperimental.commands.commands. The server then attaches it to the call snippets of---@callbackwrappers and of functions whose parameter lists string values, so the names or values are suggested as soon as the call is inserted.Highlighting
A grammar injection into
---comments colors what VS Code's Lua grammar leaves plain: the role and family of---@callback register shop, attribute lists such as(exact, server), and the visibility keyword of@field.Quotes
The fxmanifest and config module snippets, the snippet browser's manifest recipes and the resource wizard's new
fxmanifest.luaare written in the quote the server reports throughqbx/quote: the formatter'squote_style, or else the quote most strings of the document use. Without a running server they keep single quotes.The snippets now come from a completion provider instead of a
snippetscontribution, so VS Code's Insert Snippet list no longer shows them. The snippet browser still does.Other
qbxLua.diagnostics.rulesand the README now say that the levels aqbxlint.tomlsets take precedence, which is what the server does after the qbx-lua change.EBUSYon Windows while the built-in Git extension held the folder.Things that change for users
Two editor defaults change for Lua files:
editor.formatOnTypeandeditor.suggest.preview. Both can be turned off in user settings.These features need a server that includes the qbx-lua pull request, so this should be released after it.
Checks
npm run typecheckandnpm testpass on Windows (165 tests), with the server built from the qbx-lua branch. Not run on Linux or macOS.---@, the highlighting injection, reopening suggestions after a wrapper snippet, and the quote used by manifest snippets and the resource wizard.npm run packagewas not run.🤖 Generated with Claude Code